package zeebe.subprocess;

import io.zeebe.client.ZeebeClient;

public class SubprocessDeploy {
    public static void main(String[] args) {
        System.out.println("创建Zeebe的连接");
        ZeebeClient client = ZeebeClient.newClientBuilder()
                .brokerContactPoint("localhost:26500")
                .usePlaintext()
                .build();

        System.out.println("部署工作流");
        String bpmnPath = "bpmn/subprocess.bpmn";
        client.newDeployCommand()
                .addResourceFromClasspath(bpmnPath)
                .send()
                .join();

        System.out.println("部署AAJobWorker");
        String aaType = "AA";
        AAJobWorkerHandler aaJobWorkerHandler = new AAJobWorkerHandler(client);
        client.newWorker()
                .jobType(aaType)
                .handler(aaJobWorkerHandler)
                .open();

        System.out.println("部署BBJobWorker");
        String bbType = "BB";
        BBJobWorkerHandler bbJobWorkerHandler = new BBJobWorkerHandler(client);
        client.newWorker()
                .jobType(bbType)
                .handler(bbJobWorkerHandler)
                .open();

        System.out.println("部署CCJobWorker");
        String ccType = "CC";
        CCJobWorkerHandler ccJobWorkerHandler = new CCJobWorkerHandler(client);
        client.newWorker()
                .jobType(ccType)
                .handler(ccJobWorkerHandler)
                .open();

        System.out.println("部署DDJobWorker");
        String ddType = "DD";
        DDJobWorkerHandler ddJobWorkerHandler = new DDJobWorkerHandler(client);
        client.newWorker()
                .jobType(ddType)
                .handler(ddJobWorkerHandler)
                .open();
    }
}
